package string;

import java.util.Scanner;

public class StringDemo01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //1.开发登录几面，提示用户通过键盘输入登录名和密码
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入账号：");
            String loginName = sc.next();
            System.out.println("请输入密码：");
            String passWord = sc.next();
            //调用login方法进行判断正确则提示进入系统，错误重新输入
            if(login(loginName, passWord)){
                System.out.println("成功登陆！");
                break;
            }else{
                System.out.println("账号或密码输入错误，请重新输入");
            }
        }
    }

    public static boolean login(String loginName, String passWord){
        //2.设计登录方法，对用户登录名和密码进行正确性验证
        //假设系统内部已经存储了正确的用户名和密码
        String okloginName = "String学习";
        String okpassWord = "123456";
        //对其进行验证
        return okloginName.equals(loginName) && okpassWord.equals(passWord);

    }
}
